home *** CD-ROM | disk | FTP | other *** search
/ AGA Toolkit '97 / The AGA Toolkit '97.iso / miscellaneous / science / maths / calc / source / func.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-07  |  2.4 KB  |  81 lines

  1. /*
  2.  * Copyright (c) 1993 David I. Bell
  3.  * Permission is granted to use, distribute, or modify this source,
  4.  * provided that this copyright notice remains intact.
  5.  */
  6.  
  7.  
  8. #ifndef    FUNC_H
  9. #define    FUNC_H
  10.  
  11. #include "calc.h"
  12. #include "label.h"
  13.  
  14.  
  15. /*
  16.  * Structure of a function.
  17.  * The f_opcodes array is actually of variable size.
  18.  */
  19. typedef struct func FUNC;
  20. struct func {
  21.     FUNC *f_next;            /* next function in list */
  22.     unsigned long f_opcodecount;    /* size of opcode array */
  23.     unsigned int f_localcount;    /* number of local variables */
  24.     unsigned int f_paramcount;    /* max number of parameters */
  25.     char *f_name;            /* function name */
  26.     VALUE f_savedvalue;        /* saved value of last expression */
  27.     long f_opcodes[1];        /* array of opcodes (variable length) */
  28. };
  29.  
  30.  
  31. /*
  32.  * Amount of space needed to allocate a function of n opcodes.
  33.  */
  34. #define funcsize(n) (sizeof(FUNC) + (n) * sizeof(long))
  35.  
  36.  
  37. /*
  38.  * Size of a character pointer rounded up to a number of opcodes.
  39.  */
  40. #define PTR_SIZE ((sizeof(char *) + sizeof(long) - 1) / sizeof(long))
  41.  
  42.  
  43. /*
  44.  * The current function being compiled.
  45.  */
  46. extern FUNC *curfunc;
  47.  
  48.  
  49. /*
  50.  * Functions to handle functions.
  51.  */
  52. extern FUNC *findfunc MATH_PROTO((long index));
  53. extern char *namefunc MATH_PROTO((long index));
  54. extern BOOL evaluate MATH_PROTO((BOOL nestflag));
  55. extern long adduserfunc MATH_PROTO((char *name));
  56. extern void beginfunc MATH_PROTO((char *name, BOOL newflag));
  57. extern int builtinopcode MATH_PROTO((long index));
  58. extern char *builtinname MATH_PROTO((long index));
  59. extern int dumpop MATH_PROTO((long *pc));
  60. extern void addop MATH_PROTO((long op));
  61. extern void endfunc MATH_PROTO((void));
  62. extern void addopone MATH_PROTO((long op, long arg));
  63. extern void addoptwo MATH_PROTO((long op, long arg1, long arg2));
  64. extern void addoplabel MATH_PROTO((long op, LABEL *label));
  65. extern void addopptr MATH_PROTO((long op, char *ptr));
  66. extern void writeindexop MATH_PROTO((void));
  67. extern void showbuiltins MATH_PROTO((void));
  68. extern int getbuiltinfunc MATH_PROTO((char *name));
  69. extern void builtincheck MATH_PROTO((long index, int count));
  70. extern void addopfunction MATH_PROTO((long op, long index, int count));
  71. extern void showfunctions MATH_PROTO((void));
  72. extern void initfunctions MATH_PROTO((void));
  73. extern void clearopt MATH_PROTO((void));
  74. extern void updateoldvalue MATH_PROTO((FUNC *fp));
  75. extern void calculate MATH_PROTO((FUNC *fp, int argcount));
  76. extern VALUE builtinfunc MATH_PROTO((long index, int argcount, VALUE *stck));
  77.  
  78. #endif
  79.  
  80. /* END CODE */
  81.